package com.cn.activitiNSV.configuration.httpclient;

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;


/**
 * @author Voyager
 */
@Configuration
public class CustomPoolingHttpClientConnectionManager{

    @Autowired
    private Environment environment;

    @Bean
    public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager() {
        PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(20, TimeUnit.SECONDS);
        // 最大连接数
        poolingHttpClientConnectionManager.setMaxTotal(20);
        // 路由基数
        poolingHttpClientConnectionManager.setDefaultMaxPerRoute(20);
        return poolingHttpClientConnectionManager;
    }
}
